{% extends 'base.html' %}
{% block title %}个人中心{% endblock %}
{% block head %}
<link rel="stylesheet" href="{{ url_for('static',filename='css/base1.css') }}">
{% endblock %}
{% block main %}

<div class="form-container">
<h3 class="page-title">个人中心</h3>
  <div class="form-group">
      <label for="exampleInputPassword1">用户名</label>
    <input type="text" name="login_name" class="form-control" id="box_name" placeholder="{{ captal.username }}" readonly="true">
  </div>
  <div class="form-group">
      <label for="exampleInputPassword1">昵称</label>
    <input type="text" name="login_nickname" class="form-control" id="box_nickname" placeholder="{{ captal.nickname }}">
  </div>
    <div class="form-group">
        <label for="exampleInputPassword1">QQ号</label>
        {% if captal.qq_number == 'None' %}
            <input type="text" name="login_qq_number" class="form-control" id="box_qq_number" placeholder="">
        {% else %}
            <input type="text" name="login_qq_number" class="form-control" id="box_qq_number" placeholder="{{ captal.qq_number }}">
        {% endif %}
  </div>
    <div class="form-group">
        <label for="exampleInputPassword1">手机号</label>
        {% if captal.phone == 'None' %}
            <input type="text" name="login_phone" class="form-control" id="box_phone" placeholder="">
        {% else %}
            <input type="text" name="login_phone" class="form-control" id="box_phone" placeholder="{{ captal.phone }}">
        {% endif %}

  </div>
    <div id="search_pass_link">
        <label id="message" style="color: red;"></label>
    </div>
{#    文件的#}
{#  <div class="form-group">#}
{#    <label for="exampleInputFile">File input</label>#}
{#    <input type="file" id="exampleInputFile">#}
{#    <p class="help-block">Example block-level help text here.</p>#}
{#  </div>#}
    <div class="sumbit" >
    <button type="submit" class="btn btn-default" id="submit" onclick="login()">提交</button>
        <button type="button" class="btn btn-default" onclick="click_register()">返回</button>
        </div>
</div>
{% endblock %}
{% block jsna %}
<script>
        //返回
        function click_register() {
             window.location.href="/index";
        }
        // 提交
        function login() {
            var name = document.getElementById('box_name').value;
            var nickname = document.getElementById('box_nickname').value;
            var qq_number = document.getElementById('box_qq_number').value;
            var phone = document.getElementById('box_phone').value;
            $.ajax({
                headers: {"X-CSRFToken": '{{ csrf_token }}'},
                url: "/center/center_check",
                type: 'POST',
                tradition: true,
                dataType: 'json',
                data: {'username': name, 'nickname': nickname, 'qq_number':qq_number, 'phone':phone},
                success: function (data) {
                    if (data.state == 'success') {
                        document.getElementById("message").innerHTML = '登录成功'
                        window.location.href = data.url
                    } else if (data.state == 'fail') {
                        $('#message').html(data.message)
                        setTimeout(function () {
                            $('#message').html('');
                        }, 5000)
                    }
                }
            })
        }
</script>
{% endblock %}